<?php
session_start();

include_once( 'config.php' );

	$user = array();
	$arr = array();
	$totalList=array();
	$user['$user_name'] = array('username'=>user_name,'pwd'=>pwd,'key'=>WB_AKEY);//这里可以添加多用户调用，每行一个
	$count = isset($_GET['count']) && $_GET['count'] ? intval($_GET['count']) : 20;//调用条数
	$count = $count ? $count : 20;
	
foreach($user as $u){
	$getjson = 'https://'.$u['username'].':'.$u['pwd'].'@api.weibo.com/2/friendships/friends.json?source='.$u['key'].'&uid=1883369085&cursor=0';//新浪api
	echo 'getjson:'.$getjson.'<br/>';
	$getjson2='https://13660569061:900110@api.weibo.com/2/statuses/user_timeline.json?source=2575049723&uid=3253096524';
	$content = file_get_contents($getjson2); //自制函数,远程调用
	$weibo = json_decode($content, true);
	print_r($weibo);
}
 function showWeibo($weibo) {
	print_r($weibo['next_cursor']);
	echo '<br/>';
	print_r($weibo['total_number']);
	$arr = $weibo['users'];
	//print_r($arr);
	for($i=0;$i<$count;$i++){
		$arr1 = $arr["$i"]['screen_name'];
		$totalList[]=$arr1;
	}
	print_r($totalList);
}

 function file_get_contents_curl($url) {
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
      curl_setopt($ch, CURLOPT_URL, $url);
      $data = curl_exec($ch);
      curl_close($ch);
      return $data;
      }
	  
	 function post($url, $params) {
	         $ch = curl_init();
	         curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_HEADER, 1);
	         //curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
	         curl_setopt($ch, CURLOPT_POST, 1);
	         curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
	         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	         $data = curl_exec($ch);
	         curl_close($ch);
	         return $data;
	     }
?>
